import req from '@/services/http'
import { Pro_List, Pro_Add, Pro_Search,Pro_ImgUp,Pro_ImgDel ,Pro_Detail,Pro_Status} from '@/config/urlProduct'

const models = {
	proList(obj) {
		let { pageNum, pageSize } = obj
		return req.get(Pro_List + '?pageNum=' + pageNum + '&pageSize=' + pageSize)
	},
	proAdd(obj) {
		return req.post(Pro_Add, obj)
	},
	proSearch(obj) {
		let { pageNum, pageSize, productName, productDesc } = obj
		console.log(productName);
		if (!productName) {
			console.log('desc');
			return req.get(Pro_Search + `?pageNum=${pageNum}&pageSize=${pageSize}&productDesc=${productDesc}`)
		} else {
			console.log('name');
			return req.get(Pro_Search + `?pageNum=${pageNum}&pageSize=${pageSize}&productName=${productName}`)
		}
	},
	Pro_Status(obj) {
		return req.post(Pro_Status,obj)
	},
	// 图片上传
	proImgUp() {
		return req.post(Pro_ImgUp)
	},
	// 图片删除
	proImgDel(obj) {
		return req.post(Pro_ImgDel,obj)
	},
	// 商品详情
	proDetail(categoryId) {
		return req.get(Pro_Detail+'?categoryId='+categoryId)
	}
}

export default models